package tools

import (
	"github.com/zeromicro/go-zero/core/jsonx"
	"github.com/zeromicro/go-zero/core/logx"
)

func BeanToJson(any interface{}) string {
	toString, err := jsonx.MarshalToString(any)
	if err != nil {
		logx.Error("beanToJson err:", err.Error())
		return ""
	}
	return toString
}

func JsonToBean(jsonStr string, targetObj any) {
	err := jsonx.UnmarshalFromString(jsonStr, targetObj)
	if err != nil {
		logx.Error("JsonToBean err:", err.Error())
		return
	}
}
